package
{
	import flash.display.Loader;
	import flash.display.Sprite;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.net.URLRequest;
	import flash.system.ApplicationDomain;
	import flash.system.LoaderContext;
	import ywh.ui.MyTreeCellRenderer;
	import ywh.ui.TreeMenu;
	import ywh.ui.TreeMenuDataProvider;
	
	/**
	 * ...
	 * @author 杨伟华
	 */
	public class Test_CourseTree extends Sprite
	{
		var tree:TreeMenu;
		
		public function Test_CourseTree()
		{
			this.addEventListener(Event.ADDED_TO_STAGE, this_addedToStage);
		}
		
		private function this_addedToStage(e:Event):void
		{
			removeEventListener(Event.ADDED_TO_STAGE, this_addedToStage);
			this.stage.scaleMode = StageScaleMode.NO_SCALE;
			var loader:Loader = new Loader();
			var context:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);
			loader.contentLoaderInfo.addEventListener(Event.INIT, init);
			loader.load(new URLRequest("com_slider.swf"), context);
		}
		
		private function init(e:Event):void
		{
			var data:XML =  <items>	
					<item label="引言"   m="1" />
					<item label="创伤的诊断现状"   m="2" />
					<item label="创伤的概念"   m="3" />
					<item label="不同视角下的创伤">			
						<item label="冲突"   m="4" />
						<item label="客体关系的视角"   m="5" />
					</item>
					<item label="创伤的分类">
						<item label="简单创伤"   m="6" />
						<item label="复合型创伤"   m="7" />
					</item>
					<item label="理解创伤化的关键点"   m="8" />
					<item label="创伤的机制">
						<item label="创伤与神经科学"   m="9" />
						<item label="创伤与失衡"   m="10" />
						<item label="创伤与焦虑"   m="11" />
						<item label="创伤与丧失"   m="12" />
						<item label="创伤的记忆加工机制"   m="13" />
						<item label="创伤的机制">
							<item label="创伤与神经科学"   m="9" />
							<item label="创伤与失衡"   m="10" />
							<item label="创伤与焦虑"   m="11" />
							<item label="创伤与丧失"   m="12" />
							<item label="创伤的记忆加工机制"   m="13" />
						</item>
					</item>
					<item label="创伤的治疗"   m="14" />
					<item label="案例"   m="15" />
				</items>;
			tree = new TreeMenu();
			tree.setStyle('cellRenderer', MyTreeCellRenderer);
			tree.setSize(400, 300);
			tree.rowHeight = 30;
			tree.dataProvider = new TreeMenuDataProvider(data);
			addChild(tree);
		}
	
	}

}